package org.objective.base;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 *
 * @author gus
 */
public class CommonObject<T>
{
    private long oid;
    private Reference<T> reference;

    public CommonObject(long oid)
    {
        this.oid = oid;
        this.reference = null;
    }

    public CommonObject(long oid, T object)
    {
        this.oid = oid;
        this.reference = new WeakReference<T>(object);
    }

    public long getOid()
    {
        return oid;
    }

    public T getObject()
    {
        if (reference != null)
        {
            return reference.get();
        }
        return null;
    }

    public void clean()
    {
        reference.clear();
    }
}
